// quadtrees.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "quadtrees.h"
#include "string.h"
#include "stdio.h"


#define MAX_LOADSTRING 100
#define   NULL_BRUSH 5

void colorare(HDC hdc ,	PAINTSTRUCT ps,int R,int G,int B,int left,int top,int right,int bottom)
{
	HBRUSH currentbrush=CreateSolidBrush(RGB(R,G,B));
	RECT *r;
	r=(RECT*)malloc(sizeof(RECT));

	r->left=left;r->top=top;r->right=right;r->bottom=bottom;
	FillRect(hdc,r,currentbrush);
}

// Global Variables:
HINSTANCE hInst;								// current instance
TCHAR szTitle[MAX_LOADSTRING];					// The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];			// the main window class name

// Forward declarations of functions included in this code module:
ATOM				MyRegisterClass(HINSTANCE hInstance);
BOOL				InitInstance(HINSTANCE, int);
LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK	About(HWND, UINT, WPARAM, LPARAM);
int ok=0,kk=0;
int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

 	// TODO: Place code here.
	MSG msg;
	HACCEL hAccelTable;

	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_QUADTREES, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow))
	{
		return FALSE;
	}

	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_QUADTREES));

	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	return (int) msg.wParam;
}



//
//  FUNCTION: MyRegisterClass()
//
//  PURPOSE: Registers the window class.
//
//  COMMENTS:
//
//    This function and its usage are only necessary if you want this code
//    to be compatible with Win32 systems prior to the 'RegisterClassEx'
//    function that was added to Windows 95. It is important to call this function
//    so that the application will get 'well formed' small icons associated
//    with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX);

	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc	= WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= hInstance;
	wcex.hIcon			= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_QUADTREES));
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName	= MAKEINTRESOURCE(IDC_QUADTREES);
	wcex.lpszClassName	= szWindowClass;
	wcex.hIconSm		= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

	return RegisterClassEx(&wcex);
}

//
//   FUNCTION: InitInstance(HINSTANCE, int)
//
//   PURPOSE: Saves instance handle and creates main window
//
//   COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND hWnd;

   hInst = hInstance; // Store instance handle in our global variable

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, CW_USEDEFAULT,2000,750, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);
   return TRUE;
}

//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
RECT *r,*r2;
void colorare(HDC hdc,PAINTSTRUCT ps,int R,int G,int B,int left,int top,int right,int bottom)
 {if(R==255&G==255&B==255)
	  {Rectangle(hdc,left,top,right,bottom);
	   return;}
  HBRUSH currentbrush=CreateSolidBrush(RGB(R,G,B));
  r=(RECT*)malloc(sizeof(RECT));
  r->left=left;r->top=top;r->right=right;r->bottom=bottom;
  FillRect(hdc,r,currentbrush);
  free(r);
 }

void patrat(int col,int left,int top,int right,int bottom)
{r=(RECT*)malloc(sizeof(RECT));
 r->left=left;r->top=top;r->right=right;r->bottom=bottom;
 R=c[col].R;G=c[col].G;B=c[col].B;
}
int col;
void colorare_arbore();
void depthfirst(nod *root);
BOOL CALLBACK DialogProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{switch(msg){
	case WM_INITDIALOG: return TRUE;
	case WM_COMMAND:{
		switch(wParam){
			case IDC_negru:col=1;break;
			case IDC_rosu:col=2;break;
			case IDC_verde:col=3;break;
			case IDC_albastru:col=4;break;
			case IDC_galben:col=5;break;
			case IDC_violet:col=6;break;
			case IDC_bleumarin:col=7;break;
			case IDC_alb:col=8;break;
			case IDC_BUTTON01:{if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[1].culoare=col;
							   left=p[1].left;top=p[1].top;right=p[1].right;bottom=p[1].bottom;
							   ok=1;
							   patrat(col,p[1].left,p[1].top,p[1].right,p[1].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							  }
						break;
			case IDC_BUTTON02: {
				                if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[2].culoare=col;
							   left=p[2].left;top=p[2].top;right=p[2].right;bottom=p[2].bottom;
							   ok=1;
							   patrat(col,p[2].left,p[2].top,p[2].right,p[2].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON03: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[3].culoare=col;
							   left=p[3].left;top=p[3].top;right=p[3].right;bottom=p[3].bottom;
							   ok=1;
							   patrat(col,p[3].left,p[3].top,p[3].right,p[3].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON04: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[4].culoare=col;
							   left=p[4].left;top=p[4].top;right=p[4].right;bottom=p[4].bottom;
							   ok=1;
							   patrat(col,p[4].left,p[4].top,p[4].right,p[4].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON05: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[5].culoare=col;
							   left=p[5].left;top=p[5].top;right=p[5].right;bottom=p[5].bottom;
							   ok=1;
							   patrat(col,p[5].left,p[5].top,p[5].right,p[5].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON06: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[6].culoare=col;
							   left=p[6].left;top=p[6].top;right=p[6].right;bottom=p[6].bottom;
							   ok=1;
							   patrat(col,p[6].left,p[6].top,p[6].right,p[6].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON07: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[7].culoare=col;
							   left=p[7].left;top=p[7].top;right=p[7].right;bottom=p[7].bottom;
							   ok=1;
							   patrat(col,p[7].left,p[7].top,p[7].right,p[7].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON08: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[8].culoare=col;
							   left=p[8].left;top=p[8].top;right=p[8].right;bottom=p[8].bottom;
							   ok=1;
							   patrat(col,p[8].left,p[8].top,p[8].right,p[8].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON09: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[9].culoare=col;
							   left=p[9].left;top=p[9].top;right=p[9].right;bottom=p[9].bottom;
							   ok=1;
							   patrat(col,p[9].left,p[9].top,p[9].right,p[9].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON10: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[10].culoare=col;
							   left=p[10].left;top=p[10].top;right=p[10].right;bottom=p[10].bottom;
							   ok=1;
							   patrat(col,p[10].left,p[10].top,p[10].right,p[10].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON11: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[11].culoare=col;
							   left=p[11].left;top=p[11].top;right=p[11].right;bottom=p[11].bottom;
							   ok=1;
							   patrat(col,p[11].left,p[11].top,p[11].right,p[11].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON12: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[12].culoare=col;
							   left=p[12].left;top=p[12].top;right=p[12].right;bottom=p[12].bottom;
							   ok=1;
							   patrat(col,p[12].left,p[12].top,p[12].right,p[12].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON13: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[13].culoare=col;
							   left=p[13].left;top=p[13].top;right=p[13].right;bottom=p[13].bottom;
							   ok=1;
							   patrat(col,p[13].left,p[13].top,p[13].right,p[13].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON14: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[14].culoare=col;
							   left=p[14].left;top=p[14].top;right=p[14].right;bottom=p[14].bottom;
							   ok=1;
							   patrat(col,p[14].left,p[14].top,p[14].right,p[14].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON15: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[15].culoare=col;
							   left=p[15].left;top=p[15].top;right=p[15].right;bottom=p[15].bottom;
							   ok=1;
							   patrat(col,p[15].left,p[15].top,p[15].right,p[15].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON16: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[16].culoare=col;
							   left=p[16].left;top=p[16].top;right=p[16].right;bottom=p[16].bottom;
							   ok=1;
							   patrat(col,p[16].left,p[16].top,p[16].right,p[16].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON17: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[17].culoare=col;
							   left=p[17].left;top=p[17].top;right=p[17].right;bottom=p[17].bottom;
							   ok=1;
							   patrat(col,p[17].left,p[17].top,p[17].right,p[17].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON18: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[18].culoare=col;
							   left=p[18].left;top=p[18].top;right=p[18].right;bottom=p[18].bottom;
							   ok=1;
							   patrat(col,p[18].left,p[18].top,p[18].right,p[18].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON19: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[19].culoare=col;
							   left=p[19].left;top=p[19].top;right=p[19].right;bottom=p[19].bottom;
							   ok=1;
							   patrat(col,p[19].left,p[19].top,p[19].right,p[19].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON20: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[20].culoare=col;
							   left=p[20].left;top=p[20].top;right=p[20].right;bottom=p[20].bottom;
							   ok=1;
							   patrat(col,p[20].left,p[20].top,p[20].right,p[20].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON21: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[21].culoare=col;
							   left=p[21].left;top=p[21].top;right=p[21].right;bottom=p[21].bottom;
							   ok=1;
							   patrat(col,p[21].left,p[21].top,p[21].right,p[21].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON22: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[22].culoare=col;
							   left=p[22].left;top=p[22].top;right=p[22].right;bottom=p[22].bottom;
							   ok=1;
							   patrat(col,p[22].left,p[22].top,p[22].right,p[22].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON23: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[23].culoare=col;
							   left=p[23].left;top=p[23].top;right=p[23].right;bottom=p[23].bottom;
							   ok=1;
							   patrat(col,p[23].left,p[23].top,p[23].right,p[23].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON24: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[24].culoare=col;
							   left=p[24].left;top=p[24].top;right=p[24].right;bottom=p[24].bottom;
							   ok=1;
							   patrat(col,p[24].left,p[24].top,p[24].right,p[24].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON25: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[25].culoare=col;
							   left=p[25].left;top=p[25].top;right=p[25].right;bottom=p[25].bottom;
							   ok=1;
							   patrat(col,p[25].left,p[25].top,p[25].right,p[25].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON26: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[26].culoare=col;
							   left=p[26].left;top=p[26].top;right=p[26].right;bottom=p[26].bottom;
							   ok=1;
							   patrat(col,p[26].left,p[26].top,p[26].right,p[26].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON27: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[27].culoare=col;
							   left=p[27].left;top=p[27].top;right=p[27].right;bottom=p[27].bottom;
							   ok=1;
							   patrat(col,p[27].left,p[27].top,p[27].right,p[27].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON28: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[28].culoare=col;
							   left=p[28].left;top=p[28].top;right=p[28].right;bottom=p[28].bottom;
							   ok=1;
							   patrat(col,p[28].left,p[28].top,p[28].right,p[28].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON29: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[29].culoare=col;
							   left=p[29].left;top=p[29].top;right=p[29].right;bottom=p[29].bottom;
							   ok=1;
							   patrat(col,p[29].left,p[29].top,p[29].right,p[29].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON30: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[30].culoare=col;
							   left=p[30].left;top=p[30].top;right=p[30].right;bottom=p[30].bottom;
							   ok=1;
							   patrat(col,p[30].left,p[30].top,p[30].right,p[30].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON31: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[31].culoare=col;
							   left=p[31].left;top=p[31].top;right=p[31].right;bottom=p[31].bottom;
							   ok=1;
							   patrat(col,p[31].left,p[31].top,p[31].right,p[31].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON32: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[32].culoare=col;
							   left=p[32].left;top=p[32].top;right=p[32].right;bottom=p[32].bottom;
							   ok=1;
							   patrat(col,p[32].left,p[32].top,p[32].right,p[32].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON33: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[33].culoare=col;
							   left=p[33].left;top=p[33].top;right=p[33].right;bottom=p[33].bottom;
							   ok=1;
							   patrat(col,p[33].left,p[33].top,p[33].right,p[33].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON34: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[34].culoare=col;
							   left=p[34].left;top=p[34].top;right=p[34].right;bottom=p[34].bottom;
							   ok=1;
							   patrat(col,p[34].left,p[34].top,p[34].right,p[34].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON35: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[35].culoare=col;
							   left=p[35].left;top=p[35].top;right=p[35].right;bottom=p[35].bottom;
							   ok=1;
							   patrat(col,p[35].left,p[35].top,p[35].right,p[35].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON36: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[36].culoare=col;
							   left=p[36].left;top=p[36].top;right=p[36].right;bottom=p[36].bottom;
							   ok=1;
							   patrat(col,p[36].left,p[36].top,p[36].right,p[36].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON37: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[37].culoare=col;
							   left=p[37].left;top=p[37].top;right=p[37].right;bottom=p[37].bottom;
							   ok=1;
							   patrat(col,p[37].left,p[37].top,p[37].right,p[37].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON38: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[38].culoare=col;
							   left=p[38].left;top=p[38].top;right=p[38].right;bottom=p[38].bottom;
							   ok=1;
							   patrat(col,p[38].left,p[38].top,p[38].right,p[38].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON39: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[39].culoare=col;
							   left=p[39].left;top=p[39].top;right=p[39].right;bottom=p[39].bottom;
							   ok=1;
							   patrat(col,p[39].left,p[39].top,p[39].right,p[39].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON40: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[40].culoare=col;
							   left=p[40].left;top=p[40].top;right=p[40].right;bottom=p[40].bottom;
							   ok=1;
							   patrat(col,p[40].left,p[40].top,p[40].right,p[40].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON41: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[41].culoare=col;
							   left=p[41].left;top=p[41].top;right=p[41].right;bottom=p[41].bottom;
							   ok=1;
							   patrat(col,p[41].left,p[41].top,p[41].right,p[41].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON42: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[42].culoare=col;
							   left=p[42].left;top=p[42].top;right=p[42].right;bottom=p[42].bottom;
							   ok=1;
							   patrat(col,p[42].left,p[42].top,p[42].right,p[42].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON43: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[43].culoare=col;
							   left=p[43].left;top=p[43].top;right=p[43].right;bottom=p[43].bottom;
							   ok=1;
							   patrat(col,p[43].left,p[43].top,p[43].right,p[43].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON44: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[44].culoare=col;
							   left=p[44].left;top=p[44].top;right=p[44].right;bottom=p[44].bottom;
							   ok=1;
							   patrat(col,p[44].left,p[44].top,p[44].right,p[44].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON45: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[45].culoare=col;
							   left=p[45].left;top=p[45].top;right=p[45].right;bottom=p[45].bottom;
							   ok=1;
							   patrat(col,p[45].left,p[45].top,p[45].right,p[45].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON46: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[46].culoare=col;
							   left=p[46].left;top=p[46].top;right=p[46].right;bottom=p[46].bottom;
							   ok=1;
							   patrat(col,p[46].left,p[46].top,p[46].right,p[46].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON47: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[47].culoare=col;
							   left=p[47].left;top=p[47].top;right=p[47].right;bottom=p[47].bottom;
							   ok=1;
							   patrat(col,p[47].left,p[47].top,p[47].right,p[47].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON48: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[48].culoare=col;
							   left=p[48].left;top=p[48].top;right=p[48].right;bottom=p[48].bottom;
							   ok=1;
							   patrat(col,p[48].left,p[48].top,p[48].right,p[48].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON49: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[49].culoare=col;
							   left=p[49].left;top=p[49].top;right=p[49].right;bottom=p[49].bottom;
							   ok=1;
							   patrat(col,p[49].left,p[49].top,p[49].right,p[49].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON50: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[50].culoare=col;
							   left=p[50].left;top=p[50].top;right=p[50].right;bottom=p[50].bottom;
							   ok=1;
							   patrat(col,p[50].left,p[50].top,p[50].right,p[50].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON51: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[51].culoare=col;
							   left=p[51].left;top=p[51].top;right=p[51].right;bottom=p[51].bottom;
							   ok=1;
							   patrat(col,p[51].left,p[51].top,p[51].right,p[51].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON52: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[52].culoare=col;
							   left=p[52].left;top=p[52].top;right=p[52].right;bottom=p[52].bottom;
							   ok=1;
							   patrat(col,p[52].left,p[52].top,p[52].right,p[52].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON53: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[53].culoare=col;
							   left=p[53].left;top=p[53].top;right=p[53].right;bottom=p[53].bottom;
							   ok=1;
							   patrat(col,p[53].left,p[53].top,p[53].right,p[53].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON54: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[54].culoare=col;
							   left=p[54].left;top=p[54].top;right=p[54].right;bottom=p[54].bottom;
							   ok=1;
							   patrat(col,p[54].left,p[54].top,p[54].right,p[54].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
		    case IDC_BUTTON55: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[55].culoare=col;
							   left=p[55].left;top=p[55].top;right=p[55].right;bottom=p[55].bottom;
							   ok=1;
							   patrat(col,p[55].left,p[55].top,p[55].right,p[55].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON56: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[56].culoare=col;
							   left=p[56].left;top=p[56].top;right=p[56].right;bottom=p[56].bottom;
							   ok=1;
							   patrat(col,p[56].left,p[56].top,p[56].right,p[56].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON57: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[57].culoare=col;
							   left=p[57].left;top=p[57].top;right=p[57].right;bottom=p[57].bottom;
							   ok=1;
							   patrat(col,p[57].left,p[57].top,p[57].right,p[57].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON58: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[58].culoare=col;
							   left=p[58].left;top=p[58].top;right=p[58].right;bottom=p[58].bottom;
							   ok=1;
							   patrat(col,p[58].left,p[58].top,p[58].right,p[58].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON59: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[59].culoare=col;
							   left=p[59].left;top=p[59].top;right=p[59].right;bottom=p[59].bottom;
							   ok=1;
							   patrat(col,p[59].left,p[59].top,p[59].right,p[59].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON60: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[60].culoare=col;
							   left=p[60].left;top=p[60].top;right=p[60].right;bottom=p[60].bottom;
							   ok=1;
							   patrat(col,p[60].left,p[60].top,p[60].right,p[60].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON61: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[61].culoare=col;
							   left=p[61].left;top=p[61].top;right=p[61].right;bottom=p[61].bottom;
							   ok=1;
							   patrat(col,p[61].left,p[61].top,p[61].right,p[61].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON62: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[62].culoare=col;
							   left=p[62].left;top=p[62].top;right=p[62].right;bottom=p[62].bottom;
							   ok=1;
							   patrat(col,p[62].left,p[62].top,p[62].right,p[62].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break;
			case IDC_BUTTON63: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[63].culoare=col;
							   left=p[63].left;top=p[63].top;right=p[63].right;bottom=p[63].bottom;
							   ok=1;
							   patrat(col,p[63].left,p[63].top,p[63].right,p[63].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON64: {if(col==0)
									{MessageBox(hWnd2,"Nu ati selectat culoarea dorita","Eroare",NULL);break;}
							   p[64].culoare=col;
							   left=p[64].left;top=p[64].top;right=p[64].right;bottom=p[64].bottom;
							   ok=1;
							   patrat(col,p[64].left,p[64].top,p[64].right,p[64].bottom);
							   InvalidateRect(hWnd2,r,FALSE);
							   free(r);
							   EndDialog(Dialog,0);
							   }
						break; 
			case IDC_BUTTON65:ok=2;
							  EndDialog(Dialog,1);
							  r=(RECT*)malloc(sizeof(RECT));
							  r->left=0;r->top=250;r->right=1500;r->bottom=750;
							  InvalidateRect(hWnd2,r,FALSE);
						break;
							}
						break;
					}
	case WM_CLOSE:
		EndDialog(Dialog,0);
        break;  
	default: return FALSE;
			}
 return TRUE;
}

void depthfirst(nod *root)
{if(root==NULL)
	 return;
 depthfirst(root->NW);
 depthfirst(root->NE);
 depthfirst(root->SW);
 depthfirst(root->SE);
}
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd2, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc,DC;
	switch (message)
	{
	case WM_COMMAND:
		
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd2, About);
			break;
		case IDM_EXIT:
				{
					MessageBox(hWnd2,"Va multumim!","Bye Bye", NULL);
					DestroyWindow(hWnd2);
				}
			break;
		case ID_FILE_CREAREHARTA:
				{grid=1;initt=1;
				 Dialog=CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_PROPPAGE_LARGE), hWnd2,reinterpret_cast<DLGPROC>(DialogProc));
				 if(Dialog==NULL)
					 MessageBox(hWnd2,"eroare dialog","eroare",NULL);
				 ShowWindow(Dialog,SW_SHOW);
				 InvalidateRect(hWnd2,NULL,FALSE);
				 break;
				}
		default:
			return DefWindowProc(hWnd2, message, wParam, lParam);
		break;
		}
		case WM_PAINT:{
			HPEN blackPen;
		hdc = BeginPaint(hWnd2, &ps);
		// TODO: Add any drawing code here...
		if(initt!=1){
		char text[100];
		strcpy(text,"Bine ati venit!");
		TextOut(hdc,630,280,text,strlen(text));
		strcpy(text,"Pentru a incepe demonstratia");
		TextOut(hdc,580,300,text,strlen(text));
		strcpy(text,"Va rugam selectati optiunea creare harta din meniul file");
		TextOut(hdc,480,320,text,strlen(text));}
		if(grid==1){HBRUSH alb=CreateSolidBrush(RGB(255,255,255));
					r=(RECT*)malloc(sizeof(RECT));
					r->left=0;r->top=0;r->right=2000;r->bottom=750;
					FillRect(hdc,r,alb);
					free(r);
			   int t,y;
			   t=1000;
			   y=25;
			   for(int i=1;i<=8;i++)
			   {
				   for(int j=1;j<=8;j++)
				   {
					   Rectangle(hdc,t,y,t+25,y+25);
					   t=t+25;
				   }
				   y=y+25;
				   t=1000;
			   }
			   grid=0;
		   }
		if(ok==1){
			 colorare(hdc,ps,R,G,B,left,top,right,bottom);
			 ok=0;
			 //InvalidateRect(hWnd2,NULL,TRUE);
			 Dialog=CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_PROPPAGE_LARGE), hWnd2,reinterpret_cast<DLGPROC>(DialogProc));
			 if(Dialog==NULL)
					 MessageBox(hWnd2,"eroare dialog","eroare",NULL);
			 ShowWindow(Dialog,SW_SHOW);
			 UpdateWindow(hWnd2);
			 break;
				}
		if(ok==2){
				  colorare_arbore();//depthfirst(head);
				  char g[10];
				  strcpy(g,head->index);
				  nod *root2=(nod*)malloc(sizeof(nod));

						//g[1]=NULL;
						TextOut(hdc,609,255,g,strlen(g));
						SetTextColor(hdc,RGB(0,0,255));
						nod *crt,*prev;
						crt=(nod*)malloc(sizeof(nod));
						colorare(hdc,ps,c[head->culoare].R,c[head->culoare].G,c[head->culoare].B,620,270,635,285);
						if(head->NW!=NULL)
						{
							
							crt=head;
							int p,q;char v[10];
							p=180;q=330;
								colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,p,q,p+15,q+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,p-9,q-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            p=p+300;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,p,q,p+15,q+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,p-9,q-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            p=p+300;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,p,q,p+15,q+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,p-9,q-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            p=p+300;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,p,q,p+15,q+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,p-9,q-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								p=187;q=330;
				                 for(int i=1;i<=4;i++)
					               {
						               MoveToEx(hdc,627,285,NULL);
				                       LineTo(hdc,p,q);
					                   p=p+300;
				                   }

						}
						prev=(nod*)malloc(sizeof(nod));
						prev=crt;
						crt=prev->NW;
						char v[10];
						int x,y;
						x=100;y=420;
						if(crt->NW!=NULL)
						{
							colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+60;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+60;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+60;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
						x=x+20;
						}
						x=405;
						crt=prev->NE;
						if(crt->NW!=NULL)
						{
							colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+60;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+60;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+60;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=x+20;
						}
						x=710;
						crt=prev->SW;
						if(crt->NW!=NULL)
						{
							colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+60;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+60;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+60;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=x+20;

						}
						x=1015;
						crt=prev->SE;
						if(crt->NW!=NULL)
						{
							colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+60;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+60;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+60;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-16,y-20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
						}
						int r,l;
				r=187;l=345;
				x=107;y=420;
				crt=prev->NW;
				for(int i=1;i<=4;i++)
				{
					if(crt->NW!=NULL)
					{
					for(int j=1;j<=4;j++)
					{
						MoveToEx(hdc,r,l,NULL);
				       LineTo(hdc,x,y);
					   if(j==4)
						   x=x+20;
					   else
					   x=x+60;
					}
					}
					if(i==1)
						{
							x=412;
							crt=prev->NE;
					    }
					if(i==2)
						{
							x=717;
							crt=prev->SW;
					    }
					   
					if(i==3)
						{
							x=1022;
							crt=prev->SE;
					    }
					r=r+300;
				}
				nod *prev1=(nod*)malloc(sizeof(nod));
				prev1=prev;
				prev=prev1->NW;
				crt=prev->NW;
				x=6;y=550;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x+3,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x+3,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x+3,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x+3,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=13;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,107,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}
							

				
				x=90;
				crt=prev->NE;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x+3,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x+3,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x+3,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x+3,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=97;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,167,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}
				x=164;
				crt=prev->SW;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x+3,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=171;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,227,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}
				x=238;
				crt=prev->SE;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=245;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,287,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}


				//////////
				prev=prev1->NE;
				crt=prev->NW;
				x=319;y=550;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=326;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,411,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}
							

				
				x=403;
				crt=prev->NE;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=410;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,471,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}
				x=477;
				crt=prev->SW;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=484;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,532,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}
				x=561;
				crt=prev->SE;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=568;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,592,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}


				//////////
				prev=prev1->SW;
				crt=prev->NW;
				x=700;y=550;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=707;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,717,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}
							

				
				x=774;
				crt=prev->NE;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=781;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,767,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}
				x=858;
				crt=prev->SW;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=865;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,837,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}
				x=932;
				crt=prev->SE;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=939;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,896,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}
				//////
				prev=prev1->SE;
				crt=prev->NW;
				x=1025;y=550;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=1032;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,1022,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}
							

				
				x=1099;
				crt=prev->NE;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=1106;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,1082,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}
				x=1173;
				crt=prev->SW;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=1180;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,1142,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}
				x=1250;
				crt=prev->SE;
				if(crt->NW!=NULL)
				{
					colorare(hdc,ps,c[crt->NW->culoare].R,c[crt->NW->culoare].G,c[crt->NW->culoare].B,x,y,x+15,y+15);
								root2=crt->NW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->NE->culoare].R,c[crt->NE->culoare].G,c[crt->NE->culoare].B,x,y,x+15,y+15);
								root2=crt->NE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SW->culoare].R,c[crt->SW->culoare].G,c[crt->SW->culoare].B,x,y,x+15,y+15);
								root2=crt->SW;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
					            x=x+16;
								colorare(hdc,ps,c[crt->SE->culoare].R,c[crt->SE->culoare].G,c[crt->SE->culoare].B,x,y,x+15,y+15);
								root2=crt->SE;
								strcpy(v,root2->index);
								TextOut(hdc,x-1,y+20,v,strlen(v));
								SetTextColor(hdc,RGB(0,0,255));
								x=1257;
								for(int i=1;i<=4;i++)
					                       {
						                      MoveToEx(hdc,1202,435,NULL);
				                                    LineTo(hdc,x,y);
					                                        x=x+16;
								           }
				}




							
						ok=0;
						}

		 

		EndPaint(hWnd2, &ps);
		//UpdateWindow(hWnd2);
					  }
		break;
		default://InvalidateRect(hWnd2,NULL,FALSE);
		return DefWindowProc(hWnd2, message, wParam, lParam);
	}
	return 0;
}

// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(lParam);
	switch (message)
	{
	case WM_INITDIALOG:
		return (INT_PTR)TRUE;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
		{
			EndDialog(hDlg, LOWORD(wParam));
			return (INT_PTR)TRUE;
		}
		break;
	}
	return (INT_PTR)FALSE;
}
